-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Align casting methods with Python behaviour #497
Conversation
x.__complex__()
, unrestrict cross-kind casting in respective array methods
Per what we decided upon in our last array meeting (see #486 (comment)), I've updated this PR with my take on how to we align the spec's casting methods with Python's behaviour. I have some thorough testing for how Python's casting works in https://gist.github.com/honno/98371048b4d5b9fc4a003377a714e827, which I'll have to tidy up (will be useful anyway for the test suite). As @seberg noted, NumPy seems to 100% follow Python casting behaviour for its arrays (if we're not including a small divergence in behaviour for NumPy scalars). Only notable thing maybe is NumPy not aligning with Python's Not 100% on language used, happy to hear what folk think. Will sleep on it anyway. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realised I should probably special case non-finite values for __bool__
.
Think this is ready @seberg @asmeurer? With the follow up of specifying |
I believe all discussion points have been resolved. I'll go ahead and merge. Any further changes can be addressed in follow-up PRs. Thanks, all! |
Resolves #486 (adding
x.__complex__()
).Per interest in having the builtin casting methods (
__bool__
/__int__
/__float__
/__complex__
/__index__
) support arrays of a different dtype kind, this PR also changes the language to clarify that adopters can support such casting. EDIT: now aligning casting methods with Python behaviour generally(I opted against requiring cross-kind casting in this PR—see #486 (comment))See #486 (comment)